home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / mystston.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  11KB  |  372 lines

  1. /***************************************************************************
  2.  
  3. Mysterious Stones memory map (preliminary)
  4.  
  5. driver by Nicola Salmoria
  6.  
  7. MAIN BOARD:
  8.  
  9. 0000-0fff RAM
  10. 1000-13ff Video RAM
  11. 1400-17ff Attribute RAM
  12. 1800-19ff Background video RAM #1
  13. 1a00-1bff Background attribute RAM #1
  14. 1c00-1fff probably scratchpad RAM, contains a copy of the background without objects
  15. 4000-ffff ROM
  16.  
  17. read
  18. 2000      IN0
  19.           bit 7 = coin 2 (must also cause a NMI)
  20.           bit 6 = coin 1 (must also cause a NMI)
  21.           bit 0-5 = player 1 controls
  22. 2010      IN1
  23.           bit 7 = start 2
  24.           bit 6 = start 1
  25.           bit 0-5 = player 2 controls (cocktail only)
  26. 2020      DSW1
  27.           bit 3-7 = probably unused
  28.           bit 2 = ?
  29.           bit 1 = ?
  30.           bit 0 = lives
  31. 2030      DSW2
  32.           bit 7 = vblank
  33.           bit 6 = coctail/upright (0 = upright)
  34.           bit 4-5 = probably unused
  35.           bit 0-3 = coins per play
  36.  
  37. write
  38. 0780-07df sprites
  39. 2000      Tile RAM bank select?
  40. 2010      Commands for the sound CPU?
  41. 2020      background scroll
  42. 2030      ?
  43. 2040      ?
  44. 2060-2077 palette
  45.  
  46. Known problems:
  47.  
  48. * Some dipswitches may not be mapped correctly.
  49.  
  50. ***************************************************************************/
  51.  
  52. #include "driver.h"
  53. #include "vidhrdw/generic.h"
  54. #include "cpu/m6502/m6502.h"
  55.  
  56.  
  57.  
  58. extern unsigned char *mystston_videoram2,*mystston_colorram2;
  59. extern size_t mystston_videoram2_size;
  60. extern unsigned char *mystston_scroll;
  61.  
  62. void mystston_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  63. int mystston_vh_start(void);
  64. void mystston_vh_stop(void);
  65. WRITE_HANDLER( mystston_2000_w );
  66. void mystston_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  67.  
  68.  
  69.  
  70. int mystston_interrupt(void)
  71. {
  72.     static int coin;
  73.  
  74.  
  75.     if ((readinputport(0) & 0xc0) != 0xc0)
  76.     {
  77.         if (coin == 0)
  78.         {
  79.             coin = 1;
  80.             return nmi_interrupt();
  81.         }
  82.     }
  83.     else coin = 0;
  84.  
  85.     return interrupt();
  86. }
  87.  
  88.  
  89. static int psg_latch;
  90.  
  91. WRITE_HANDLER( mystston_8910_latch_w )
  92. {
  93.     psg_latch = data;
  94. }
  95.  
  96. WRITE_HANDLER( mystston_8910_control_w )
  97. {
  98.     static int last;
  99.  
  100.  
  101.     /* bit 5 goes to 8910 #0 BDIR pin  */
  102.     if ((last & 0x20) == 0x20 && (data & 0x20) == 0x00)
  103.     {
  104.         /* bit 4 goes to the 8910 #0 BC1 pin */
  105.         if (last & 0x10)
  106.             AY8910_control_port_0_w(0,psg_latch);
  107.         else
  108.             AY8910_write_port_0_w(0,psg_latch);
  109.     }
  110.     /* bit 7 goes to 8910 #1 BDIR pin  */
  111.     if ((last & 0x80) == 0x80 && (data & 0x80) == 0x00)
  112.     {
  113.         /* bit 6 goes to the 8910 #1 BC1 pin */
  114.         if (last & 0x40)
  115.             AY8910_control_port_1_w(0,psg_latch);
  116.         else
  117.             AY8910_write_port_1_w(0,psg_latch);
  118.     }
  119.  
  120.     last = data;
  121. }
  122.  
  123.  
  124.  
  125. static struct MemoryReadAddress readmem[] =
  126. {
  127.     { 0x0000, 0x077f, MRA_RAM },
  128.     { 0x0800, 0x0fff, MRA_RAM },    /* work RAM? */
  129.     { 0x1000, 0x1fff, MRA_RAM },
  130.     { 0x2000, 0x2000, input_port_0_r },
  131.     { 0x2010, 0x2010, input_port_1_r },
  132.     { 0x2020, 0x2020, input_port_2_r },
  133.     { 0x2030, 0x2030, input_port_3_r },
  134.     { 0x4000, 0xffff, MRA_ROM },
  135.     { -1 }    /* end of table */
  136. };
  137.  
  138. static struct MemoryWriteAddress writemem[] =
  139. {
  140.     { 0x0000, 0x077f, MWA_RAM },
  141.     { 0x0780, 0x07df, MWA_RAM, &spriteram, &spriteram_size },
  142.     { 0x0800, 0x0fff, MWA_RAM },    /* work RAM? */
  143.     { 0x1000, 0x13ff, MWA_RAM, &mystston_videoram2, &mystston_videoram2_size },
  144.     { 0x1400, 0x17ff, MWA_RAM, &mystston_colorram2 },
  145.     { 0x1800, 0x19ff, videoram_w, &videoram, &videoram_size },
  146.     { 0x1a00, 0x1bff, colorram_w, &colorram },
  147.     { 0x1c00, 0x1fff, MWA_RAM },    /* work RAM? This gets copied to videoram */
  148.     { 0x2000, 0x2000, mystston_2000_w },    /* flip screen & coin counters */
  149.     { 0x2010, 0x2010, watchdog_reset_w },    /* or IRQ acknowledge maybe? */
  150.     { 0x2020, 0x2020, MWA_RAM, &mystston_scroll },
  151.     { 0x2030, 0x2030, mystston_8910_latch_w },
  152.     { 0x2040, 0x2040, mystston_8910_control_w },
  153.     { 0x2060, 0x2077, paletteram_BBGGGRRR_w, &paletteram },
  154.     { 0x4000, 0xffff, MWA_ROM },
  155.     { -1 }    /* end of table */
  156. };
  157.  
  158.  
  159.  
  160.  
  161. INPUT_PORTS_START( mystston )
  162.     PORT_START    /* IN0 */
  163.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
  164.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_4WAY )
  165.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY )
  166.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_4WAY )
  167.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
  168.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
  169.     PORT_BIT_IMPULSE( 0x40, IP_ACTIVE_LOW, IPT_COIN2, 1 )
  170.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN1, 1 )
  171.  
  172.     PORT_START    /* IN1 */
  173.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL )
  174.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_4WAY | IPF_COCKTAIL )
  175.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY | IPF_COCKTAIL )
  176.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_4WAY | IPF_COCKTAIL )
  177.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  178.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  179.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
  180.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  181.  
  182.     PORT_START    /* DSW1 */
  183.     PORT_DIPNAME(0x01, 0x01, DEF_STR( Lives ) )
  184.     PORT_DIPSETTING(   0x01, "3" )
  185.     PORT_DIPSETTING(   0x00, "5" )
  186.     PORT_DIPNAME(0x02, 0x02, DEF_STR( Unknown ) )
  187.     PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
  188.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  189.     PORT_DIPNAME(0x04, 0x04, DEF_STR( Demo_Sounds ) )
  190.     PORT_DIPSETTING(   0x04, DEF_STR( Off ) )
  191.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  192.     PORT_DIPNAME(0x08, 0x08, DEF_STR( Unknown ) )
  193.     PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
  194.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  195.     PORT_DIPNAME(0x10, 0x10, DEF_STR( Unknown ) )
  196.     PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
  197.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  198.     PORT_DIPNAME(0x20, 0x20, DEF_STR( Unknown ) )
  199.     PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
  200.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  201.     PORT_DIPNAME(0x40, 0x40, DEF_STR( Unknown ) )
  202.     PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
  203.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  204.     PORT_DIPNAME(0x80, 0x80, DEF_STR( Unknown ) )
  205.     PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
  206.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  207.  
  208.     PORT_START    /* DSW2 */
  209.     PORT_DIPNAME(0x03, 0x03, DEF_STR( Coin_B ) )
  210.     PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
  211.     PORT_DIPSETTING(   0x03, DEF_STR( 1C_1C ) )
  212.     PORT_DIPSETTING(   0x02, DEF_STR( 1C_2C ) )
  213.     PORT_DIPSETTING(   0x01, DEF_STR( 1C_3C ) )
  214.     PORT_DIPNAME(0x0c, 0x0c, DEF_STR( Coin_A ) )
  215.     PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
  216.     PORT_DIPSETTING(   0x0c, DEF_STR( 1C_1C ) )
  217.     PORT_DIPSETTING(   0x08, DEF_STR( 1C_2C ) )
  218.     PORT_DIPSETTING(   0x04, DEF_STR( 1C_3C ) )
  219.     PORT_DIPNAME(0x10, 0x10, DEF_STR( Unknown ) )
  220.     PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
  221.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  222.     PORT_DIPNAME(0x20, 0x20, DEF_STR( Unknown ) )
  223.     PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
  224.     PORT_DIPSETTING(   0x00, DEF_STR( On ) )
  225.     PORT_DIPNAME(0x40, 0x00, DEF_STR( Cabinet ) )
  226.     PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
  227.     PORT_DIPSETTING(   0x40, DEF_STR( Cocktail ) )
  228.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
  229. INPUT_PORTS_END
  230.  
  231.  
  232.  
  233. static struct GfxLayout charlayout =
  234. {
  235.     8,8,    /* 8*8 characters */
  236.     2048,    /* 2048 characters */
  237.     3,    /* 3 bits per pixel */
  238.     { 2*2048*8*8, 2048*8*8, 0 },    /* the bitplanes are separated */
  239.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  240.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  241.     8*8    /* every char takes 8 consecutive bytes */
  242. };
  243.  
  244. static struct GfxLayout spritelayout =
  245. {
  246.     16,16,  /* 16*16 sprites */
  247.     512,    /* 512 sprites */
  248.     3,    /* 3 bits per pixel */
  249.     { 2*512*16*16, 512*16*16, 0 },    /* the bitplanes are separated */
  250.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  251.             0, 1, 2, 3, 4, 5, 6, 7 },
  252.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  253.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  254.     32*8    /* every sprite takes 16 consecutive bytes */
  255. };
  256.  
  257. static struct GfxLayout tilelayout =
  258. {
  259.     16,16,  /* 16*16 tiles */
  260.     512,    /* 512 tiles */
  261.     3,    /* 3 bits per pixel */
  262.     { 2*512*16*16, 512*16*16, 0 },    /* the bitplanes are separated */
  263.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  264.             0, 1, 2, 3, 4, 5, 6, 7 },
  265.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  266.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  267.     32*8    /* every tile takes 16 consecutive bytes */
  268. };
  269.  
  270. static struct GfxDecodeInfo gfxdecodeinfo[] =
  271. {
  272.     { REGION_GFX1, 0, &charlayout,   3*8, 4 },
  273.     { REGION_GFX2, 0, &tilelayout,   2*8, 1 },
  274.     { REGION_GFX1, 0, &spritelayout,   0, 2 },
  275.     { -1 } /* end of array */
  276. };
  277.  
  278.  
  279.  
  280. static struct AY8910interface ay8910_interface =
  281. {
  282.     2,      /* 2 chips */
  283.     1500000,        /* 1.5 MHz ? */
  284.     { 30, 30 },
  285.     { 0 },
  286.     { 0 },
  287.     { 0 },
  288.     { 0 }
  289. };
  290.  
  291.  
  292.  
  293. static struct MachineDriver machine_driver_mystston =
  294. {
  295.     /* basic machine hardware */
  296.     {
  297.         {
  298.             CPU_M6502,
  299.             1500000,    /* 1.5 MHz ???? */
  300.             readmem,writemem,0,0,
  301.             mystston_interrupt,16    /* ? controls music tempo */
  302.         },
  303.     },
  304.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  305.     1,    /* single CPU, no need for interleaving */
  306.     0,
  307.  
  308.     /* video hardware */
  309.     32*8, 32*8, { 0*8, 32*8-1, 1*8, 31*8-1 },
  310.     gfxdecodeinfo,
  311.     24+32, 24+32,
  312.     mystston_vh_convert_color_prom,
  313.  
  314.     VIDEO_TYPE_RASTER|VIDEO_MODIFIES_PALETTE,
  315.     0,
  316.     mystston_vh_start,
  317.     mystston_vh_stop,
  318.     mystston_vh_screenrefresh,
  319.  
  320.     /* sound hardware */
  321.     0,0,0,0,
  322.     {
  323.         {
  324.             SOUND_AY8910,
  325.             &ay8910_interface
  326.         }
  327.     }
  328. };
  329.  
  330.  
  331.  
  332.  
  333.  
  334. /***************************************************************************
  335.  
  336.   Mysterious Stones driver
  337.  
  338. ***************************************************************************/
  339.  
  340. ROM_START( mystston )
  341.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  342.     ROM_LOAD( "ms0",          0x4000, 0x2000, 0x6dacc05f )
  343.     ROM_LOAD( "ms1",          0x6000, 0x2000, 0xa3546df7 )
  344.     ROM_LOAD( "ms2",          0x8000, 0x2000, 0x43bc6182 )
  345.     ROM_LOAD( "ms3",          0xa000, 0x2000, 0x9322222b )
  346.     ROM_LOAD( "ms4",          0xc000, 0x2000, 0x47cefe9b )
  347.     ROM_LOAD( "ms5",          0xe000, 0x2000, 0xb37ae12b )
  348.  
  349.     ROM_REGION( 0x0c000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  350.     ROM_LOAD( "ms6",          0x00000, 0x2000, 0x85c83806 )
  351.     ROM_LOAD( "ms9",          0x02000, 0x2000, 0xb146c6ab )
  352.     ROM_LOAD( "ms7",          0x04000, 0x2000, 0xd025f84d )
  353.     ROM_LOAD( "ms10",         0x06000, 0x2000, 0xd85015b5 )
  354.     ROM_LOAD( "ms8",          0x08000, 0x2000, 0x53765d89 )
  355.     ROM_LOAD( "ms11",         0x0a000, 0x2000, 0x919ee527 )
  356.  
  357.     ROM_REGION( 0x0c000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  358.     ROM_LOAD( "ms12",         0x00000, 0x2000, 0x72d8331d )
  359.     ROM_LOAD( "ms13",         0x02000, 0x2000, 0x845a1f9b )
  360.     ROM_LOAD( "ms14",         0x04000, 0x2000, 0x822874b0 )
  361.     ROM_LOAD( "ms15",         0x06000, 0x2000, 0x4594e53c )
  362.     ROM_LOAD( "ms16",         0x08000, 0x2000, 0x2f470b0f )
  363.     ROM_LOAD( "ms17",         0x0a000, 0x2000, 0x38966d1b )
  364.  
  365.     ROM_REGION( 0x0020, REGION_PROMS )
  366.     ROM_LOAD( "ic61",         0x0000, 0x0020, 0xe802d6cf )
  367. ROM_END
  368.  
  369.  
  370.  
  371. GAME( 1984, mystston, 0, mystston, mystston, 0, ROT270, "Technos", "Mysterious Stones" )
  372.